#ifndef GAMEBOARD_H_INCLUDED
#define GAMEBOARD_H_INCLUDED

#include "common.h"

#include "player.h"
#include "box.h"
#include "floor.h"
#include "target.h"
#include "wall.h"
#include "player.h"

#include <vector>
#include <stack>
#include <utility>
#include "empty.h"

struct Movement {
    int fromRow;
    int fromCol;
    int toRow;
    int toCol;
};

class GameBoard{
    private:
        Player *_player;

        ALLEGRO_BITMAP* _renderImg;
        int _nMoves;
        std::stack<Movement> boxMoves;

        bool eval_move_player(int, int, int, int);
        bool move_box(int, int, int, int);
        bool move_box_repulse(int, int);
        bool eval_move_box(int, int);
        bool eval_box_fixed(int, int);
        int  eval_poles(int, int);

        std::vector< std::pair<int,int> > _target_indexes;

    public:

        GameBoard();
        GameBoard(Player* p, matrixBlock m, std::vector< std::pair<int,int> > target_indexes);
        matrixBlock _board;
        ALLEGRO_BITMAP* render();
        GameBoard* copy();

        inline int& playerRow(){ return _player->posRow(); };
        inline int& playerCol(){ return _player->posCol(); };

        bool move_player(int);
        void move_boxes();
        bool check_stage_complete();

        ~GameBoard();
};


#endif // GAMEBOARD_H_INCLUDED
